IF OBJECT_ID('dbo.GetMetricAvailablePeriods') IS NOT NULL
BEGIN
    DROP PROCEDURE dbo.GetMetricAvailablePeriods
    IF OBJECT_ID('dbo.GetMetricAvailablePeriods') IS NOT NULL
        PRINT '<<< FAILED DROPPING PROCEDURE dbo.GetMetricAvailablePeriods >>>'
    ELSE
        PRINT '<<< DROPPED PROCEDURE dbo.GetMetricAvailablePeriods >>>'
END
go
-- =======================================================================
-- Procedure Name: dbo.GetMetricAvailablePeriods
--
-- Author:      Chris Bernad, Parallax Consulting LLC
--
-- Create date: 10/22/2008
--
-- Description: Returns list of Metric Report Period
--
-- Parameters:  @PeriodType - Retruns all period based on type
--              
-- Returns:     INT, 0=Success, -1=Error
--
-- SampleCall:
-- EXECUTE dbo.GetMetricAvailablePeriods 'Weekly'
--
--------------------------------------------------------------------------
-- Date        Initials  Modification
--------------------------------------------------------------------------
-- 10/24/08      CB        Created

-- =======================================================================
CREATE PROCEDURE [dbo].[GetMetricAvailablePeriods]
(
	@PeriodType varchar(50)
)
AS

	SELECT PeriodStartDate,	PeriodDescription
	  FROM InfoEdMetricSnapshots
	 WHERE PeriodType = @PeriodType
	ORDER BY PeriodStartDate DESC
	
GO
IF OBJECT_ID('dbo.GetMetricAvailablePeriods') IS NOT NULL
    PRINT '<<< CREATED PROCEDURE dbo.GetMetricAvailablePeriods >>>'
ELSE
    PRINT '<<< FAILED CREATING PROCEDURE dbo.GetMetricAvailablePeriods >>>'
GO


GRANT EXECUTE ON dbo.GetMetricAvailablePeriods TO InsightReport,Insight
GO	